package org.seanye.com.junitrunnerui.view;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.graphics.Image;
import org.seanye.com.junitrunnerui.Activator;

public class ImageManager {

	private ImageManager() {
	}

	private static final String ICONS = "icons/";
	private static final String JUNIT_ICONS = "junit/";
	private static ImageRegistry registry = JFaceResources.getImageRegistry();

	public static Image getImage(String key) {
		Image image = registry.get(key);
		if (image == null) {
			ImageDescriptor imageDescriptor = Activator
					.getImageDescriptor(ICONS + key);
			image = imageDescriptor.createImage();
			registry.put(key, imageDescriptor.createImage());
		}
		return image;
	}

	public static Image getJunitImage(String key) {
		return getImage(JUNIT_ICONS + key);
	}
}
